<?php

namespace App\Http\Controllers\Admin;

use App\Repositories\ManagerRepo;
use Illuminate\Http\Request;
use Hash;

class ManagerController extends BaseController
{
    protected $managerRepo;

    public function _initialize()
    {
        $this->managerRepo = new ManagerRepo;
    }

    public function all()
    {
        return $this->sucRes(200,$this->managerRepo->getAll());   
    }
     public function del(Request $request)
    {
        $id = $request->id;
        $this->managerRepo->del($id);
        return $this->sucRes(200);   
    }
    public function add(Request $request)
    {
        $input = $request->only(['name','password','role_id']);
        $this->managerRepo->create($input);
        return $this->sucRes(200);   
    }

    public function edit(Request $request)
    {
        $input = $request->only(['name','role_id','email']);
        $id = $request->id;
        $this->managerRepo->update($id,$input);
        return $this->sucRes(200);   
    }
    public function editPassword(Request $request)
    {
        $id = $request->id;
        $password = $request->password;
        $this->managerRepo->editPassword($id,$password);
        return $this->sucRes(200);
    }
}   
